/**
* minjs.DataSet class
* @class minjs.DataSet
*/
minjs.DataSet = function(){
	var records = [];
	var fields = [];
	
	this._getRecords = function(){return records;}
	this._getFields = function(){return fields;}
}

minjs.DataSet.prototype.getRecordCount = function(){
	return this._getRecords().length;
}

minjs.DataSet.prototype.getRecord = function(index){
	return this._getRecords()[index];
}

minjs.DataSet.prototype.addRecord = function(/*minjs.DataSet.Record*/ record){
	//this._getRecords().push(record);	// shouldn't we check that 'record instanceof minjs.DataSet.Record' ???
	var rec = (record instanceof minjs.DataSet.Record) ? record : new minjs.DataSet.Record(record ? record : {});
	this._getRecords().push(rec);
	return rec;
}

minjs.DataSet.prototype.getFieldCount = function(){
	return this._getFields().length;
}

minjs.DataSet.prototype.getField = function(index){
	return this._getFields()[index];
}

// minjs.DataSet.prototype.addField = function(field){
	// var fld = (field instanceof minjs.DataSet.Field) ? fld : new minjs.DataSet.Field(fld ? fld : {});
	// this._getFields().push(fld);
	// return fld;
// }
minjs.DataSet.prototype.addField = function(name, type){
	var field = new minjs.DataSet.Field(name, type);
	this._getFields().push(field);
	return field;
}

/**
* minjs.DataSet.Record class
* @class minjs.DataSet.Record
*/
minjs.DataSet.Record = function(data){
	var state = minjs.DataSet.Record.VALID;
	this._getData = function(){return data;}
	this._setState = function(newState){state = newstate;}
	this._getState = function(){return state;}
}

minjs.DataSet.Record.State = {
	VALID: 0,
	ADDED: 1,
	DELETED: 2,
	UPDATED: 3
};

minjs.DataSet.Record.prototype.setValue = function(key, value){
	this._getData()[key] = value;
}

minjs.DataSet.Record.prototype.getValue = function(key){
	return this._getData()[key];
}

minjs.DataSet.Record.prototype.getState = function(){
	return this._getState();
}

/**
* minjs.DataSet.Field class
* @class minjs.DataSet.Field
*/
minjs.DataSet.Field = function(name, type){
	// TODO: verify that 'type' is a constructor
	this.getName = function(){return name;}
	this.getType = function(){return type;}
}
















